package abstract1;

public abstract class Shape1 extends Object {
   public abstract void draw();//包含一个抽象方法，必须声明抽象类
    public abstract String toString();

}
class Point1 extends Shape1{
public Point1(){}
    @Override
    public void draw() {
        System.out.println('+');
    }

    @Override
    public String toString() {
        return "Point1";
    }
}
class Rectangle1 extends Shape1{

    private int width;
    private int height;
    Rectangle1(int height,int width){
        this.height=height;
        this.width=width;
    }
    @Override
    public void draw() {//实现方法
        for (int i = 0; i <height ; i++) {
            for (int j = 0; j <width ; j++) {
                System.out.print('*');
            }
            System.out.println();
        }
    }

    @Override
    public String toString() {
        return "Rectangle1";
    }
}
class ShapeTester1 {
    public static void main(String[] args) {
        Shape1[] a=new Shape1[2];
        a[0]=new Point1();
        a[1]=new Rectangle1(4,3);
        System.out.println(a[0].toString());
        a[0].draw();
        System.out.println();
        System.out.println(a[1].toString());
        a[1].draw();

    }

}

